package com.shrct.businessprocess.purchase.impl;

import com.shrct.businessprocess.project.RCProjectMoney;
import com.shrct.businessprocess.project.RCRealMoney;
import com.shrct.businessprocess.purchase.RCBasePurchaseOrder;
import com.shrct.businessprocess.purchase.RCPurchaseOrderInvoice;
import com.shrct.businessprocess.purchase.impl.RCBasePurchaseOrderImpl;
import com.shrct.businessprocess.purchase.proxy.RCPurchaseOrderInvoiceProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import java.util.Date;
import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCPURCHASEORDERINVOICE_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcpurchaseorderinvoice")
public class RCPurchaseOrderInvoiceImpl extends BaseModelObject implements RCPurchaseOrderInvoice {
  public RCPurchaseOrderInvoiceImpl() {
    super();
  }
  
  public RCPurchaseOrderInvoiceImpl(final RCBasePurchaseOrder purchaseOrder) {
    super();
    this.purchaseOrder = purchaseOrder;
  }
  
  @JoinColumn(name = "purchaseOrder_id")
  @ManyToOne(targetEntity = RCBasePurchaseOrderImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCBasePurchaseOrder purchaseOrder;
  
  public RCBasePurchaseOrder getPurchaseOrder() {
    return this.purchaseOrder;
  }
  
  public RCPurchaseOrderInvoice setPurchaseOrder(final RCBasePurchaseOrder purchaseOrder) {
    this.purchaseOrder = purchaseOrder;
    return this;			
    
  }
  
  @Embedded
  @AttributeOverrides(value = { @AttributeOverride(name = "amount", column = @Column(name = "amount_amount") ), @AttributeOverride(name = "workaround", column = @Column(name = "amount_workaround") ) } )
  @AssociationOverrides(value = @AssociationOverride(name = "exchange", joinColumns = @JoinColumn(name = "amount_exchange") ) )
  private RCProjectMoney amount = com.shrct.businessprocess.project.RCProjectMoney.create();
  
  public RCProjectMoney getAmount() {
    return this.amount;
  }
  
  public RCPurchaseOrderInvoice setAmount(final RCProjectMoney amount) {
    this.amount = amount;
    return this;			
    
  }
  
  @Embedded
  @AttributeOverrides(value = { @AttributeOverride(name = "amount", column = @Column(name = "realAmount_amount") ), @AttributeOverride(name = "exchangeRate", column = @Column(name = "realAmount_exchangeRate") ), @AttributeOverride(name = "workaround", column = @Column(name = "realAmount_workaround") ) } )
  @AssociationOverrides(value = @AssociationOverride(name = "currencyType", joinColumns = @JoinColumn(name = "realAmount_currencyType") ) )
  private RCRealMoney realAmount = com.shrct.businessprocess.project.RCRealMoney.create();
  
  public RCRealMoney getRealAmount() {
    return this.realAmount;
  }
  
  public RCPurchaseOrderInvoice setRealAmount(final RCRealMoney realAmount) {
    this.realAmount = realAmount;
    return this;			
    
  }
  
  private Date acceptDate;
  
  public Date getAcceptDate() {
    return this.acceptDate;
  }
  
  public RCPurchaseOrderInvoice setAcceptDate(final Date acceptDate) {
    this.acceptDate = acceptDate;
    return this;			
    
  }
  
  private Double taxRate;
  
  public Double getTaxRate() {
    return this.taxRate;
  }
  
  public RCPurchaseOrderInvoice setTaxRate(final Double taxRate) {
    this.taxRate = taxRate;
    return this;			
    
  }
  
  private String sid;
  
  public String getSid() {
    return this.sid;
  }
  
  public RCPurchaseOrderInvoice setSid(final String sid) {
    this.sid = sid;
    return this;			
    
  }
  
  private String comment;
  
  public String getComment() {
    return this.comment;
  }
  
  public RCPurchaseOrderInvoice setComment(final String comment) {
    this.comment = comment;
    return this;			
    
  }
  
  public static RCPurchaseOrderInvoice create(final RCBasePurchaseOrder purchaseOrder, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.purchase.RCPurchaseOrderInvoice rCPurchaseOrderInvoice = new com.shrct.businessprocess.purchase.impl.RCPurchaseOrderInvoiceImpl(
    	purchaseOrder
    );
    objectFactory.create(rCPurchaseOrderInvoice);
    return rCPurchaseOrderInvoice;			
    
  }
  
  public static RCPurchaseOrderInvoice createRCPurchaseOrderInvoiceImpl(final RCBasePurchaseOrder purchaseOrder, final IObjectFactory objectFactory, final Procedure1<RCPurchaseOrderInvoice> init) {
    com.shrct.businessprocess.purchase.RCPurchaseOrderInvoice rCPurchaseOrderInvoice = new com.shrct.businessprocess.purchase.impl.RCPurchaseOrderInvoiceImpl(
    	purchaseOrder
    );
    objectFactory.create(rCPurchaseOrderInvoice);
    init.apply(rCPurchaseOrderInvoice);
    
    return rCPurchaseOrderInvoice;			
    
  }
  
  public RCPurchaseOrderInvoiceProxy toProxy() {
    com.shrct.businessprocess.purchase.proxy.RCPurchaseOrderInvoiceProxy proxy = new com.shrct.businessprocess.purchase.proxy.RCPurchaseOrderInvoiceProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
